{include file='public/header' /}
<style>
    .edui-dialog-image-body{
        height: 220px!important;
        overflow: hidden;
    }
    .edui-dialog-image .edui-image-wrapper{
        box-sizing: border-box;
        height: 100%;
    }
    .edui-tab-nav{
        height:43px;
    }
    .edui-dialog-image .edui-image-content {
        height: 200px!important;
    }
    #demo2{
        display: flex;
        align-items: center;
    }
    #demo2 li .operate{ color: #000; display: none;}
    #demo2 li .close{position: absolute;top: 5px; right: 5px;cursor:pointer;}
    #demo2 li:hover .operate{ display: block;}
    .operate{
        position: absolute;
        right: 0;
        top: -9px;
        color: black;
        font-size: 34px;
        /* border: 1px solid red; */
        font-weight: bold;
    }
    .item_img{
        position: relative;margin-right: 10px;
    }
    .attribute{
        width: 100%;
        border: 1px solid #e6e6e6;
        margin-top:20px;
    }
    .atr{
        height: 50px;
        border: 1px solid #e6e6e6;
    }
    .ath{
        width: 100px; border-left: 1px solid #e6e6e6; border-right: 1px solid #e6e6e6;
    }
    .atd{
        display: flex;
        text-align: center;
        height: 38px;
        justify-content: center;
        align-items: center;
    }
    table input{
        text-align: center;
        border: none!important;
    }
    table td{
        border-right: 1px solid #e6e6e6;
        border-bottom: 1px solid #e6e6e6;
    }
    table td:last-child{
        border-right: none;
    }

</style>
<style>
    .user-info-head {
        width: 110px;
        height: 110px;
        position: relative;
        display: inline-block;
        border-radius: 50%;
        border: 2px solid #eee;
    }

    .user-info-head:hover:after {
        content: '\e624';
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        color: #eee;
        background: rgba(0, 0, 0, 0.5);
        font-family: layui-icon;
        font-size: 28px;
        font-style: normal;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        cursor: pointer;
        line-height: 110px;
        border-radius: 50%;
    }

    .user-info-head img {
        width: 110px;
        height: 110px;
        border-radius: 50%;
    }

    .info-list-item {
        position: relative;
        padding-bottom: 8px;
    }

    .info-list-item > .layui-icon {
        position: absolute;
    }

    .info-list-item > p {
        padding-left: 30px;
    }

    .dash {
        border-bottom: 1px dashed #ccc;
        margin: 15px 0;
    }

    .bd-list-item {
        padding: 14px 0;
        border-bottom: 1px solid #e8e8e8;
        position: relative;
    }

    .bd-list-item .bd-list-item-img {
        width: 48px;
        height: 48px;
        line-height: 48px;
        margin-right: 12px;
        display: inline-block;
        vertical-align: middle;
    }

    .bd-list-item .bd-list-item-content {
        display: inline-block;
        vertical-align: middle;
    }

    .bd-list-item .bd-list-item-lable {
        margin-bottom: 4px;
        color: #333;
    }

    .bd-list-item .bd-list-item-oper {
        position: absolute;
        right: 0;
        top: 50%;
        text-decoration: none !important;
        cursor: pointer;
        transform: translateY(-50%);
    }

    .user-info-form .layui-form-item {
        margin-bottom: 25px;
    }
</style>
</head>
<body>


<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <!-- 左 -->
        <div class="layui-col-sm12 layui-col-md3">
            <div class="layui-card">
                <div class="layui-card-body" style="padding: 25px;">
                    <div class="text-center layui-text">
                        <span id="thumb">
                        <div class="user-info-head" id="imgHead">
                            <img  {notempty name="$row.thumb"}src="{$row.thumb}"{/notempty}/>
                        </div>
                    </span>

                        <h2 style="padding-top: 20px;"></h2>
                        <p style="padding-top: 8px;">{$row.name}</p>
                    </div>
                    <div class="layui-text" style="padding-top: 30px;">
                        <div class="info-list-item">
                            <i class="layui-icon layui-icon-username"></i>
                            <p>{$row.name}</p>
                        </div>
                        <div class="info-list-item">
                            <i class="layui-icon layui-icon-release"></i>
                            <p>{$row.description}</p>
                        </div>
                        <div class="info-list-item">
                            <i class="layui-icon layui-icon-location"></i>
                            <p>{$row.address}</p>
                        </div>
                    </div>
                    <div class="dash"></div>
                    <h3>标签</h3>
                    <div class="layui-badge-list" style="padding-top: 6px;">
                        <span class="layui-badge layui-bg-gray">很有想法的</span>
                        <span class="layui-badge layui-bg-gray">专注设计</span>
                        <span class="layui-badge layui-bg-gray">辣~</span>
                        <span class="layui-badge layui-bg-gray">大长腿</span>
                        <span class="layui-badge layui-bg-gray">川妹子</span>
                        <span class="layui-badge layui-bg-gray">海纳百川</span>
                    </div>
                </div>
            </div>
        </div>
        <!-- 右 -->
        <div class="layui-col-sm12 layui-col-md9">
            <div class="layui-card">
                <div class="layui-card-body">

                    <div class="layui-tab layui-tab-brief" lay-filter="userInfoTab">
                        <ul class="layui-tab-title">
                            <li class="layui-this">基本信息</li>

                        </ul>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">

                                <div class="layui-form user-info-form layui-text"
                                     style="max-width: 400px;padding-top: 25px;">
                                    <div class="layui-form-item">
                                    <label class="layui-form-label">邮箱:</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="email" value="{$row.email}"
                                               class="layui-input" lay-verify="required" required/>
                                    </div>
                                </div>
                                    <input type="hidden" id="avatar" name="thumb" value="{$row.thumb}">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">机构名称:</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="name" value="{$row.name}"
                                                   class="layui-input" lay-verify="required" required/>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">

                                        <label class="layui-form-label">机构简介:</label>
                                        <p> <span style="color: red ">字数限制 15 字</span></p>
                                        <div class="layui-input-block">
                                            <textarea name="description" placeholder="机构简介" class="layui-textarea">{$row.description}</textarea>
                                        </div>

                                    </div>

                                    <div class="layui-upload">
                                        <label class="layui-form-label">机构轮播图</label>
                                        <!--<p> <span style="color: red ">建议图片大小 4M</span></p>-->
                                        <button type="button" class="layui-btn" id="test2">多图片上传</button>
                                        <blockquote class="layui-elem-quote layui-quote-nm " style="width:500px;margin-top: 10px;margin-left: 100px">
                                            预览图：
                                            <div class="layui-upload-list" id="demo2">
                                                {if isset($row.image)}
                                                {foreach $row.image as $v}
                                                <li class="item_img"><div class="operate"></i><i  class="close layui-icon"></i></div>
                                                    <img src="{$v??''}" class="layui-upload-img" width="60">
                                                    <input type="hidden" name="image[]" value="{$v??''}">
                                                </li>
                                               {/foreach}
                                                {/if}
                                            </div>
                                        </blockquote>
                                    </div>

                                    <div class="layui-form-item">
                                        <label for="" class="layui-form-label">视频 </label>
                                        <div class="layui-input-block">
                                            <div class="layui-upload">
                                                <p> <span style="color: red ">建议视频大小 4M</span></p>
                                                <button type="button" class="layui-btn layui-btn-sm uploadPic"><i class="layui-icon">&#xe67c;</i>视频上传</button>
                                                <div class="layui-upload-list" >
                                                    <ul class="layui-upload-box layui-clear">
                                                        {if isset($row.video)}
                                                        <li style="margin-left: -50px">
                                                            <video  id='video' src="{$row.video}" width="500" height="240" controls autobuffer></video>
                                                        </li>
                                                        {/if}
                                                    </ul>
                                                    <input type="hidden" name="video" class="layui-upload-input" value="{$row.video??''}">
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label">街道地址:</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="address" maxlength="100" value="{$row.address}" class="layui-input" lay-verify="required" required/>
                                        </div>
                                    </div>

                                    <div class="layui-form-item">  <label class="layui-form-label">联系电话:</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="phone" value="{$row.phone}"
                                                   class="layui-input" lay-verify="required" required/>
                                        </div>
                                    </div>

                                    <div class="layui-upload" style="margin: 20px 0;">
                                        <label class="layui-form-label">服务电话</label>

                                        <button type="button" class="layui-btn" id="attribute"><i class="layui-icon"></i>添加电话</button>
                                        <table class="attribute" style="margin-top: 10px;margin-left: 110px;">
                                            <tr class="atr">
                                                <th style="width: 200px;text-align:center">服务电话</th>
                                                <th style="width: 80px;text-align:center">操作</th>
                                            </tr>
                                            {notempty name="$row.service_phone"}
                                            {foreach $row.service_phone as $k=>$v}
                                            <tr>
                                                <td>
                                                    <input type='text' name='service_phone[]' placeholder='服务电话'
                                                           class='layui-input sl' value="{$v}">
                                                </td>
                                                <td style="text-align: center">
                                                    <a href='javascript:;'class='layui-btn layui-btn-xs layui-btn-primary delete'  style='margin-right: 0;font-size:12px;'><span><i class='layui-icon'></i></span></a>
                                                </td>
                                            </tr>
                                            {/foreach}
                                            {/notempty}

                                        </table>
                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label">机构详情：</label>
                                        <div class="layui-input-block">
                                            <script id="container" name="content" style="width: 500px;"  type="text/plain" style="width: 98%">{$row.content|raw}</script>
                                        </div>
                                        <!--<div class="layui-input-block" style="width:600px">-->
                                         <!--<textarea name="content" id="container" lay-verify="content" class="field-content"  ></textarea>-->
                                        <!--</div>-->
                                    </div>

                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button class="layui-btn {:auth('system.organ/edit')}" lay-filter="formSubmitBas" lay-submit>
                                                更新基本信息
                                            </button>
                                        </div>
                                    </div>
                                </div>

                            </div>

                        </div>
                    </div>

                </div>
            </div>
        </div>

    </div>
</div>
{include file='public/footer' /}
<script type="text/javascript" src="/static/public/assets/libs/layui/layui.js"></script>

<script type="text/javascript" src="/static/public/assets/js/common.js?v=316"></script>

<script>
    layui.use(['layer', 'form','upload','element', 'admin','layedit'], function () {
        var $ = layui.jquery;
        var upload = layui.upload;
        var layer = layui.layer;
        var form = layui.form;
        var element = layui.element;
        var admin = layui.admin;

        var layedit = layui.layedit;
        layedit.set({
            uploadImage:{
                url:'{:__url("admin/upload/upload")}'//接口url
                ,type:''//默认post
            }});

        var Index = layedit.build('qaContent'); // 建立编辑器

        //执行实例
        var uploadInst = upload.render({
            elem: '#thumb' //绑定元素
            ,url: '{:__url("admin/upload/upload")}'
            , data: {use: 'article_thumb'}
            , done: function (res) {
                //上传完毕回调
                if (res.code == 0) {
                    $('#imgHead>img').attr('src', res.url);
                    $('#avatar').val(res.url);
                } else {
                    layer.msg(res.msg);
                }
            }
            , error: function(){
                //请求异常回调
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
        //视频上传
        $(".uploadPic").each(function (index,elem) {
            upload.render({
                elem: $(elem)
                ,url: '{:__url("admin/upload/upload")}'
                ,multiple: false
                ,accept: 'video' //视频
                ,data:{"_token":"{{ csrf_token() }}",'file_type':2}
                ,done: function(res){
                    //如果上传失败
                    if(res.code == 0){
                        layer.msg(res.msg,{icon:1},function () {
                            $(elem).parent('.layui-upload').find('.layui-upload-box').html('<li><video  id="video" src="'+res.url+'" width="500" height="240" controls autobuffer></video><p>上传成功</p></li>');
                            $(elem).parent('.layui-upload').find('.layui-upload-input').val(res.url);
                        })
                    }else {
                        layer.msg(res.msg,{icon:2})
                    }
                }
            });
        })
//多图上传
        upload.render({
            elem: '#test2',
            url: '{:__url("admin/upload/upload")}'
            //上传接口
            ,
            data:{"_token":"{{ csrf_token() }}"},
            multiple: false,

            before:function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
//                    $('#demo2').append()
                });
            },
            done: function (res) {
                //上传完毕
                if (res.code == 0) {
                    //console.log(111)
                    $('#demo2').append('<li class="item_img"><div class="operate"></i><i  class="close layui-icon"></i></div><img src="' + res.url + '" class="layui-upload-img" width="60"><input type="hidden" name="image[]" value="' + res.url + '"></li>');
                } else {
                    layer.msg(res.msg,{icon:2,time:1000})
                }
            }
        });
//点击多图上传的X,删除当前的图片
        $("body").on("click",".close",function(){
            $(this).closest("li").remove();
        });
        // 监听表单提交
        form.on('submit(formSubmitBas)', function (data) {

            data.field['content'] = $('#container').html();
            data.field["_token"]="{{ csrf_token() }}"
//            layer.msg(JSON.stringify(data.field));
            $.ajax({
                url: '{:__url("system.organ/edit")}',
                data: data.field,
                type: 'post',
                async: false,
                success: function (res) {

                    if (res.code == 0) {
                        layer.msg(res.msg);
//
//                        layer.alert(res.msg, function (index) {
//
//                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
//                            window.location.reload();//刷新父页面，注意一定要在关闭当前iframe层之前执行刷新
//                            parent.layer.close(index);
//
//
//                        })
                    } else {
                        layer.msg(res.msg);
                    }
                }
            })
            return false;
        });

        //添加课时目录
        $('#attribute').click(function(){
            $(".attribute").append("<tr>"+"<td><input type='text' name='service_phone[]' lay-verify='required' placeholder='服务电话' class='layui-input sl' ></td>" +
                    "<td style='text-align: center'><a href='javascript:;'class='layui-btn layui-btn-xs layui-btn-primary delete'  style='margin-right: 0;font-size:12px;'><span><i class='layui-icon'></i></span></a></td>"+"</tr>");

        })
        form.render('checkbox');
        $(document).on("click","span",function () {
            $(this).parents('tr').remove();
        })

        // 选择头像
        /*$('#imgHead').click(function () {
            admin.cropImg({
                imgSrc: $('#imgHead>img').attr('src'),
                onCrop: function (res) {
                    $('#imgHead>img').attr('src', res);
                }
            });
        });*/

    });
</script>
<link href="/baidu-editor/themes/default/css/umeditor.min.css" type="text/css" rel="stylesheet">
<script src="/baidu-editor/third-party/jquery.min.js"></script>
<!-- 配置文件 -->
<script type="text/javascript" src="/baidu-editor/umeditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/baidu-editor/umeditor.min.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UM.getEditor('container');
</script>